import numpy as np
import pandas as pd


class Statistic:
    def __init__(self, dataset, args):
        header = args.get('header', None)
        df = pd.read_csv(dataset, header=header)
        self.values = df.values
        self.columns = df.columns
        self.m, self.n = self.values.shape

    def run(self):
        data = {
            'count': self.m,
            'dimension': self.n
        }
        for index, column in enumerate(self.columns):
            data[str(column)] = {}
            data[str(column)]['mean'] = np.mean(self.values[:, index])
            data[str(column)]['std'] = np.std(self.values[:, index])
            data[str(column)]['max'] = np.max(self.values[:, index])
            data[str(column)]['min'] = np.min(self.values[:, index])
            data[str(column)]['P10'] = np.percentile(self.values[:, index], 10)
            data[str(column)]['P50'] = np.percentile(self.values[:, index], 50)
            data[str(column)]['P90'] = np.percentile(self.values[:, index], 90)
        return data
